package com.jia.chenjiaweb.config.realm;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.Collection;
import java.util.Set;

@Deprecated
@Slf4j
public class RedisCache<k, v> implements Cache<k, v> {
    @Autowired
    private RedisTemplate<String,String> redisTemplate;


    private String cacheName;

    public RedisCache() {

    }

    public RedisCache(String cacheName) {
        this.cacheName = cacheName;
    }

    @Override
    public v get(k k) throws CacheException {
        log.info("获得    k:{}", k);
        BoundValueOperations operations=redisTemplate.boundValueOps(k.toString());

//        String val = redisUtilService.boundValueOps(k.toString()).get();
//        if (StringUtils.isEmpty(val)) {
//            return null;
//        }
//        return (v) val;

        return null;
    }

    @Override
    public v put(k k, v v) throws CacheException {
        log.info("存储    k:{}====v:{}", k, v.toString());
//        redisUtilService.setValue(k.toString(),v.toString());
        return null;
    }

    @Override
    public v remove(k k) throws CacheException {
        return null;
    }

    @Override
    public void clear() throws CacheException {

    }

    @Override
    public int size() {
        return 0;
    }

    @Override
    public Set<k> keys() {
        return null;
    }

    @Override
    public Collection<v> values() {
        return null;
    }

}
